import Vue from 'vue'
import VueRouter from 'vue-router'
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/login',
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login.vue')
  },
  {
    path: '/pedata-w-research',
    name: 'layout',
    component: () => import('@/views/Layout.vue'),
    redirect: '/pedata-w-research/index',
    children: [
      {
        path: 'index',
        name: 'survey',
        component: () => import('@/views/ggf/Index.vue')
      },
    ]
  },
  {
    path: '*',
    redirect: '/login',
  },
  {
    path: '/404',
    redirect: '/login',
  },

]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
